package com.warm.base.design.b_memento.white;

/**
 * @Date: 2019/11/28 9:27
 * @Author: LChuang
 * @Description: 发起人
 */
public class WOriginator {

    protected String state;

    public WOriginator(){}

    /**
     * 创建一个备忘录对象
     * @return
     */
    public WMemento createMemento(){
        return new WMemento(state);
    }

    /**
     * 将发起人的状态恢复到备忘录对象所记录的状态
     */
    public void restoreMemento(WMemento m){
        this.state = m.getState();
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    @Override
    public String toString() {
        return "Originator{" +
                "state='" + state + '\'' +
                '}';
    }
}
